package com.xt.wikiperfumapi.model.wrapper;

import com.xt.wikiperfumapi.model.IngredientInfo;
import com.xt.wikiperfumapi.model.vo.IngredientVo;
import com.xt.wikiperfumapi.service.impl.FragranceNoteInfoServiceImpl;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class IngredientWrapper {

    @Resource
    FragranceNoteInfoServiceImpl fragranceNoteInfoService;

    public IngredientVo ingredientToVo(IngredientInfo info){
        IngredientVo ingredientVo=new IngredientVo();
        try {
            BeanUtils.copyProperties(ingredientVo,info);
        }catch (Exception e){
            log.info(e.getMessage());
        }
        ingredientVo.setFragranceNoteInfo(fragranceNoteInfoService.getById(info.getFragranceNoteId()));
        return ingredientVo;
    }
}
